import QtQuick 2.0
import QtGraphicalEffects 1.14

Rectangle {
    id: lightBtn
    property bool lightBtnOpened:false
    property string imageDefultSource: modelData
    property string imageLightSource: getImageSouce(imageDefultSource, 2)

    width: 128
    height: 128
    radius: 23
    color: lightBtnOpened ? "#2D8CFF" : "#272C39"
    border.width: 1
    border.color: lightBtnOpened ? "#2D8CFF" : "#44576E"
    Image{
        id: btnImg
        anchors.centerIn: parent
        source: lightBtnOpened ? imageLightSource : imageDefultSource
        fillMode: Image.PreserveAspectFit
    }
    MouseArea{
        anchors.fill: parent
//        onPressed: {
//            lightBtnOpened = true
//        }
//        onReleased: {
//            lightBtnOpened = false
//        }
        onClicked: {
            lightBtnOpened = !lightBtnOpened
        }
    }

    layer.enabled: true
    layer.effect: DropShadow {
        transparentBorder: true
        horizontalOffset: 4
        verticalOffset: 4
        spread: 0.0
    }

    function getImageSouce(source, index){
        return source.substring(0, source.lastIndexOf('.')) +"_" + String(index)+ ".png";
    }
}
